<?php

class BeController extends \Phalcon\Mvc\Controller
{

	public function initInfo()
	{

		$user_id = $this->session->get('user_id');
		$info = UserAccountTb::findFirstById($user_id);
		$this->view->setVar('info',$info);
		
	}
    public function indexAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'About');
		$this->view->setVar('content', 'be/index');
		$this->view->setVar('title', 'About');

    }
    public function forumAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Forum');
		$this->view->setVar('content', 'be/forum');
		$this->view->setVar('title', 'Forum');

		$this->initInfo();


		$user_id = $this->session->get('user_id');
		$threads = Threads::listThreads();
		$this->view->setVar("threads",$threads);
		
		
    }
    public function eventAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Event');
		$this->view->setVar('content', 'be/event');
		$this->view->setVar('title', 'Events');
    }
    public function jobAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Job');
		$this->view->setVar('content', 'be/job');
		$this->view->setVar('title', 'Jobs');
    }
    public function faqsAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Faqs');
		$this->view->setVar('content', 'be/FAQs');
		$this->view->setVar('title', 'FAQs');
    }
    public function forum_viewAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'ForumView');
		$this->view->setVar('content', 'be/forum_view');
		$this->view->setVar('title', 'ForumTitle');

		$forum_id = $_GET['fhd'];

		$forum = Threads::listThreadsInfo($forum_id);

		$replies = ThreadsReply::listReply($forum_id);
		$related = Threads::listThreadsByUserId($forum[0]->user_id);


		$this->view->setVar('forum',$forum[0]);
		$this->view->setVar('replies',$replies);
		$this->view->setVar('related',$related);

		
    }
    public function myforumAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'my_Forum');
		$this->view->setVar('content', 'be/myforum');
		$this->view->setVar('title', 'My Forum');
    }
    public function mythreadsAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Mythreads');
		$this->view->setVar('content', 'be/forum');
		$this->view->setVar('title', 'My Threads');
		$this->initInfo();

		$user_id = $this->session->get('user_id');
		$my_threads = Threads::listThreadsByUserId($user_id);
		$this->view->setVar("my_threads",$my_threads);
    }
    public function subscribedthreadsAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Subscribedthreads');
		$this->view->setVar('content', 'be/forum');
		$this->view->setVar('title', 'Subscribed Threads');
    }
    public function unansweredthreadsAction()
    {
		$this->view->setMainView('index');
		$this->view->setVar('page_name', 'Unansweredthreads');
		$this->view->setVar('content', 'be/forum');
		$this->view->setVar('title', 'Unanswered Threads');
    }

}

